<!--文章管理-->
<template>
    <div>
        <el-tabs type="border-card" v-model="activeName">
            <!--个人中心部分-->
            <el-tab-pane label="工单管理" name="second">
                <el-row :gutter="20">
                    <el-col :span="30" style="height: 100px;">
                      <h4 style="border-bottom: 1px solid #999;padding-bottom:10px">工单概览</h4>
                        <el-button  round @click="go">今日工单<span>12</span></el-button>
                        <el-button type="warning" round @click="go">未分配的工单  <span>12</span> </el-button>
                        <el-button type="info" round @click="go">已分配的工单 <span>12</span></el-button>
                        <el-button type="success" round @click="go">解决的工单 <span>12</span></el-button>
                        <el-button type="success" round style="background-color:#999" @click="go">已关闭的工单 <span>12</span></el-button>
                        <el-button type="success" round style="background-color:#666" @click="go">撤销的工单 <span>12</span></el-button>
                    </el-col>
                    <el-col :span="30">
                        <h4 style="border-bottom: 1px solid #999;padding-bottom:10px">最新工单</h4>
                    </el-col>

                    <!--<el-col :span="10">-->

                    <!--</el-col>-->
                </el-row>
                <div class="dateMsg" v-if="pageCount" style="color: red">总计<b>{{pageCount}}</b>条数据</div>
                <el-table :data="tableData" style="width: 100%" v-loading="listLoading">
                    <el-table-column prop="title" label="工单编号">
                    </el-table-column>
                    <el-table-column prop="status" label="地址" :formatter="banFormat">
                    </el-table-column>
                    <el-table-column prop="update_time" label="状态" >
                    </el-table-column>
                    <el-table-column prop="operator" label="提交时间">
                    </el-table-column>
                    <el-table-column prop="update_time" label="提交者" >
                    </el-table-column>
                    <el-table-column prop="operator" label="处理人">
                    </el-table-column>
                    <el-table-column prop="date" label="操作">
                        <template scope="scope">
                            <el-button  type="text" size="small" @click="look()">查看</el-button>
                            <el-button type="text" size="small" @click="edit()">编辑</el-button>
                            <!--<el-button v-if="scope.row.status==1" type="text" size="small" @click="forBidden()">启用</el-button>-->
                            <!--<el-button v-else type="text" size="small" @click="forBidden()">禁用</el-button>-->
                            <!--<el-button type="text" size="small" @click="bao()">报名信息</el-button>-->
                            <!--<el-button type="text" size="small" @click="del()">删除</el-button>-->
                            <!--<el-button v-else type="text" size="small" @click="forBidden(scope.row.enterprise_id,1)">禁用</el-button>-->
                        </template>
                    </el-table-column>
                </el-table>

                <div class="pagination" style="width:200px;margin-top:10px;margin-left:75% ">
                    <el-pagination layout="prev, pager, next"  :total='pageCount' @current-change="getCurrentpage" :page-size=10></el-pagination>
                </div>
            </el-tab-pane>
        </el-tabs>
    </div>
</template>
<script>
    import _http from '@/components/common/http.vue'
    import _param from '@/components/common/param.vue'
    export default {
        data() {
            return {
                userid:'',
                listLoading:false,
                currentPage:1,
                pageCount:0,
                pageAbout:{
                    userid:'',
                    title:'',
                    pageNumber:1,
                    pageSize:10
                },
                apiPort:{
///                    列表页内容接口
                    actList:"activity/list",
//                    启用禁用
                    statusC:'activity/enableOrDisable',
//                    删除接口
                    del:'activity/deleteActivity'
                },
                activeName: 'second',
                labelPosition: 'right',
                tableData: []
            };
        },
        mounted(){
            this.limit = JSON.parse(localStorage.getItem("limitList"))
            this.userid=localStorage.getItem('userId')
            this.pageAbout.userid = localStorage.getItem('userId')
            this.getCurrentpage(1)
        },
        methods: {
            found(){
                this.pageAbout.pageNumber=1
                this.getCurrentpage(1)
            },
            resetForm(formName){
                this.$refs[formName].resetFields();
            },
            //跳转到指定页
            getCurrentpage(val){
                this.listLoading=true
                var that = this
                this.currentPage = val ? val:1
                this.pageAbout.pageNumber=val ? val:1
                var params = that.querystring.stringify(this.pageAbout)
                _http.axiosRequest(that,that.apiPort.actList,params,(res)=>{
                    that.pageCount=res.data.data.total
                this.listLoading=false
                that.tableData = res.data.data.records
            })
            },
            banFormat:function(row,column){
                var ban = row[column.property];
                if ( ban == 1 ){
                    return "禁用";
                }
                return "启用";
            },
            handleClick(tab, event) {
                console.log(tab, event);
            },
            //        启用禁用
            forBidden(id,par){
                var that = this
                var param = {'id':id,status:par,userid:that.userid}
                var params = that.querystring.stringify(param)
                _http.axiosRequest(that,that.apiPort.statusC,params,(res)=>{
                    console.log(res.data)
                that.getCurrentpage(that.currentPage)
            })
            },
//            删除接口
            del(id){
                var that = this
                this.$confirm('此操作将删除该活动全部内容, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var param = {id:id,userid:that.userid}
                    var params = that.querystring.stringify(param)
                    _http.axiosRequest(that,that.apiPort.del,params,(res)=>{
                    console.log(res.data)
                that.getCurrentpage(that.currentPage)
                if(res.data.code==100){
                    that.$message({
                        message: '删除成功',
                        type: 'success'
                    });
//                    that.getCurrentpage(that.currentPage)
                }else{
                    that.$message({
                        message: res.data.msg,
                        type: 'warning'
                    });
                }
            })
            }).catch(() => {

                });


//                var that = this
//                var param = {id:id,userid:that.userid}
//                var params = that.querystring.stringify(param)
//                _http.axiosRequest(that,that.apiPort.del,params,(res)=>{
//                    console.log(res.data)
//                that.getCurrentpage(that.currentPage)
//            })
            },
            go(){
                this.$router.push({path:'/workOrder/workDetail',query:{info:1}})
            },
            bao(id){
                this.$router.push({path:'/activity/baming',query:{info:id}})
            },
            edit(id){
                this.$router.push({path:'/activity/fabuhd',query:{info:id}})
            },
            look(id){
                this.$router.push({path:'/activity/look',query:{info:id}})
            }
        }
    };
</script>